package com.greenyoung.pwiki.oss.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.greenyoung.pwiki.oss.entity.OssFileEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 文件上传
 */
@Mapper
public interface OssFileDao extends BaseMapper<OssFileEntity> {

    /**
     * 通过用户id查找用户对应的oss文件，并进行分页
     *
     * @param page   分页参数
     * @param userId 用户id
     * @return 查询到的实体数据集合经page封装
     */
    @Select("select *\n" +
            "from oss_file o\n" +
            "         left join user_file uf on uf.file_id = o.id\n" +
            "where user_id = #{userId}")
    IPage<OssFileEntity> selectPageByUserId(IPage<OssFileEntity> page, Long userId);
}
